package com.lujieni.springbootcaffeine.controller;


import com.lujieni.springbootcaffeine.cache.CaffeineCacheHolder;
import com.lujieni.springbootcaffeine.po.StudentPO;
import com.lujieni.springbootcaffeine.service.StudentCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;



@RestController
public class HelloController {


    @Autowired
    private StudentCache studentCache;

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public Object getName(String key) {
        StudentPO studentPO = studentCache.get(key);
        return studentPO;
    }

    @RequestMapping(value = "/refresh", method = RequestMethod.GET)
    public void refresh() {
        CaffeineCacheHolder.invalidateAllCache();
    }


}
